package cn.crm.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import cn.crm.bean.Province;
import cn.crm.dao.ProvinceDao;
@Repository("provinceDao")
public class ProvinceDaoImpl extends HibernateDaoSupport implements ProvinceDao {

	@Override
	public List<Province> getAll() {
		List<Province> list=super.getHibernateTemplate().find("from Province where proParentid=0");
		return list.size()>0?list:null;
	}

	@Override
	public List<Province> getAllByParentId(Integer id) {
		List<Province> list=super.getHibernateTemplate().find("from Province where proParentid=?",id);
		return list.size()>0?list:null;
	}

	@Override
	public Province getById(Integer id) {
		List<Province> list=super.getHibernateTemplate().find("from Province where proCodeid=?",id);
		return list.size()>0?list.get(0):null;
	}

}
